package util;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

/**
 * @author camilo
 */
public class Renderer extends DefaultTableCellRenderer implements TableCellRenderer {

  public static final int R = 206;
  public static final int G = 255;
  public static final int B = 221;
  private Color color;

  public Renderer() {
    super();
  }

  public Renderer(Color color) {
    super();
    this.color = color;
  }

  @Override
  public Component getTableCellRendererComponent(
          JTable table,
          Object value,
          boolean isSelected,
          boolean hasFocus,
          int row,
          int column) {

    Component result = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    result.setFont(new Font("arial", Font.PLAIN, 11));
    this.setHorizontalAlignment(SwingConstants.CENTER);

    Object ref = table.getValueAt(row, 1);
    if (ref == null) {
//      setBackground(Color.LIGHT_GRAY);
      result.setForeground(Color.green);
      result.setFont(new Font("arial", Font.ITALIC, 11));
    } else {
      result.setForeground(Color.black);
//      setBackground(null);
    }

    /*Object ref = table.getValueAt(row, 2);  
     if (ref != null && (Float.parseFloat(ref.toString()) < 0)) {  
     result.setFont(new Font("arial", Font.PLAIN, 12));  
     result.setForeground(Color.red);  
     } else {  
     result.setFont(new Font("arial", Font.PLAIN, 12));  
     result.setForeground(Color.ORANGE);  
     }*/

    return this;
  }
}
